<template>
  <div id="CreateProductStockInfo">
    <!--         Breadcrumbs -->
    <div class="breadcrumbs" style="margin: 0px;padding-top: 20px;">
      <ul>
        <li class="home"><a href="index.html" title="Go to Home Page"><strong style="font-size: 18px;">基础数据</strong></a>
          <span>/</span>
        </li>
        <li><strong>仓库信息管理</strong><span>/</span></li>
        <li><strong>新增仓库信息</strong></li>
      </ul>
    </div>
    <article class="col-main">
      <div class="my-account block block-account" style="padding-left: 20px;">

        <div class="page-title" style="border-bottom: #F1F3F6 1px solid;">
          <h2>新增仓库信息</h2>
          <hr>
        </div>

        <form action=">">
          <div class="form-group">
            <strong style="font-weight: 1000;font-size: 20px">产品系列</strong>
            &nbsp;<span style="color: red;font-size: 15px">*</span>
            <div style="padding-left: 20px;">
              <input v-on:blur="checkProductSeries" v-model="productVo.productSeries" class="form-control" placeholder="请输入产品系列" style="width: 400px;">
            </div>
          </div>

          <div class="form-group">
            <strong style="font-weight: 1000;font-size: 20px">产品型号</strong>
            &nbsp;<span style="color: red;font-size: 15px">*</span>
            <div style="padding-left: 20px;">
              <input v-on:blur="checkProductModel" v-model="productVo.productModel" class="form-control" placeholder="请输入产品型号" style="width: 400px;">
            </div>
          </div>

          <div class="form-group">
            <strong style="font-weight: 1000;font-size: 20px">产品批次</strong>
            &nbsp;<span style="color: red;font-size: 15px">*</span>
            <div style="padding-left: 20px;">
              <input v-on:blur="checkProductBatch" v-model="productVo.productBatch" class="form-control" placeholder="请输入产品批次" style="width: 400px;">
            </div>
          </div>

          <div class="form-group">
            <strong style="font-weight: 1000;font-size: 20px">存放仓库名称</strong>
            <div style="padding-left: 20px;">
              <input v-on:blur="checkStockName" v-model="productVo.storeName" class="form-control" placeholder="请输入存放仓库名称" style="width: 400px;">
            </div>
          </div>

          <div class="form-group">
            <strong style="font-weight: 1000;font-size: 20px">存放货位</strong>
            &nbsp;<span style="color: red;font-size: 15px">*</span>
            <div style="padding-left: 20px;">
              <input v-on:blur="checkStockCargoSpace" v-model="productVo.cargoSpace" class="form-control" placeholder="请输入存放货位" style="width: 400px;"></input>
            </div>
          </div>

          <div class="form-group">
            <strong style="font-weight: 1000;font-size: 20px">产品数量</strong>
            &nbsp;<span style="color: red;font-size: 15px">*</span>
            <div style="padding-left: 20px;">
              <input v-on:blur="checkProductNum" v-model="productVo.cargoNum" class="form-control" placeholder="请输入产品数量" style="width: 400px;"></input>
            </div>
          </div>

          <div class="form-group">
            <strong style="font-weight: 1000;font-size: 20px">备注</strong>
            &nbsp;<span style="color: red;font-size: 15px">*</span>
            <div style="padding-left: 20px;">
              <textarea v-model="productVo.cargoRemarks" class="form-control" placeholder="请输入备注" style="width: 400px;"></textarea>
            </div>
          </div>

          <div class="text-center" style="margin-top: 40px;padding-bottom: 30px">
            <button v-on:click="saveStockInfo" type="button" class="btn btn-primary">保存</button>
            <router-link to="ProductStockInfoList" class="btn btn-default">返回</router-link>
          </div>
        </form>

      </div>
    </article>
  </div>
</template>

<script>
export default {
  name: "CreateProductStockInfo",
  data(){
    return{
      productVo:{
        productSeries:'',
        productModel:'',
        productBatch:'',
        cargoNum:'',
        storeName:'',
        cargoSpace:'',
        cargoRemarks:''
      },
      isHavingProduct:false
    }
  },
  methods:{
    saveStockInfo(){
      if (this.checkProductSeries()){
        if (this.checkProductModel()){
          if (this.checkProductBatch()){
            if (this.checkStockName()){
              if (this.checkStockCargoSpace()){
                if (this.checkProductNum()){
                  this.$axios.post('/stock/createStock',this.productVo).then(
                    res=>{
                      this.$message({
                        showClose: true,
                        message: res.data.message,
                        type: 'success'
                      });
                      this.$router.push("/MemuBar/ProductStockInfoList");
                    }
                  ).catch(
                    res=>{
                      this.$message({
                        showClose: true,
                        message: res.data.message,
                        type: 'error'
                      });
                    }
                  )
                }
              }
            }
          }
        }
      }
    },
    checkProductSeries(){
      if (this.productVo.productSeries == ""){
        this.$message({
          showClose: true,
          message: '产品系列不可为空',
          type: 'error'
        });
        return false;
      }else {
        return true;
      }
    },
    checkProductModel(){
      if (this.productVo.productModel == ""){
        this.$message({
          showClose: true,
          message: '产品型号不可为空',
          type: 'error'
        });
        return false;
      }else {
        return true;
      }
    },
    checkProductBatch(){
      if (this.productVo.productBatch == ""){
        this.$message({
          showClose: true,
          message: '产品批次不可为空',
          type: 'error'
        });
        return false;
      }else {
        return true;
      }
    },
    checkStockName(){
      if (this.productVo.storeName == ""){
        this.$message({
          showClose: true,
          message: '仓库名字不可为空',
          type: 'error'
        });
        return false;
      }else {
        return true;
      }
    },
    checkStockCargoSpace(){
      if (this.productVo.cargoSpace == ""){
        this.$message({
          showClose: true,
          message: '存放货位不可为空',
          type: 'error'
        });
        return false;
      }else {
        return true;
      }
    },
    checkProductNum(){
      if (this.productVo.cargoNum == ""){
        this.$message({
          showClose: true,
          message: '商品数量不可为空',
          type: 'error'
        });
        return false;
      }else {
        return true;
      }
    },
  },
  created() {
  }
}
</script>

<style scoped>

</style>
